﻿using MediatR;
using SheepCultivation.API.AddliCation.EnterPriseW;
using SheepCultivation.Common.Domain;
using SheepCultivation.Common.Dto;
using SheepCultivation.Common.Infrastructure.Interface;
using SheepCultivation.Enum;

namespace SheepCultivation.API.AddliCation.AddressW
{
    public class ProvinceSeachHandler : IRequestHandler<ProvinceSeachCommon, Result>
    {
        public readonly IBaseRepository<Province> ProvinceRepository;

        public ProvinceSeachHandler(IBaseRepository<Province> provinceRepository)
        {
            ProvinceRepository = provinceRepository;
        }

        public async Task<Result> Handle(ProvinceSeachCommon request, CancellationToken cancellationToken)
        {
            var res = new Result() { Code = (int)CommonEnumCode.error };
            try
            {
                var list = ProvinceRepository.GetAll().ToList();
                res.Code = (int)CommonEnumCode.success;
                res.Data = list;
                res.Msg = "省列表";
            }
            catch (Exception ex)
            {

            }
            return res;
        }
    }
}
